package top.yuechenc.manage.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.yuechenc.manage.entity.SpRole;
import top.yuechenc.manage.entity.SpRoleDto;
import top.yuechenc.manage.mapper.SpRoleMapper;
import top.yuechenc.manage.service.RoleService;

import java.util.List;

/**角色管理服务层实现
 * @author Zhiwei Wang
 * @date 2020/3/12 16:10
 */
@Service
public class RoleServiceImpl implements RoleService {
    @Autowired
    private SpRoleMapper spRoleMapper;

    @Override
    public List<SpRoleDto> getRoleList() {
        return spRoleMapper.selectAllOV();
    }

    @Override
    public void addRole(SpRole spRole) {
        spRoleMapper.insertSelective(spRole);
    }

    @Override
    public SpRole findRoleById(String roleId) {
        return spRoleMapper.selectByPrimaryKey(roleId);
    }

    @Override
    public void updById(SpRole spRole) {
        spRoleMapper.updateByPrimaryKeySelective(spRole);
    }

    @Override
    public void delById(String roleId) {
        spRoleMapper.deleteByPrimaryKey(roleId);
    }

    @Override
    public void setRights(SpRole spRole) {
        spRoleMapper.updateByPrimaryKey(spRole);
    }
}
